package com.ymatou.iapi.livebuyer.testcase;

import java.util.Map;

import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.experimental.categories.Category;

import com.ymatou.iapi.livebuyer.parameter.SubscribeBean;
import com.ymatou.iapi.livebuyer.service.SubscribeCall;
import com.ymt.core.tool.Logger;
import com.ymt.utils.annotation.*;
import com.ymt.utils.tag.*;
import com.ymttest.database.model.LiveRoom;
import com.ymttest.database.sqlwapper.LiveRoomWapper;
import com.ymttest.utils.TestDataManager;
/**
*直播订阅
*FreeMaker Template自动生成代码
*/
@TestSuite
public class Ts_Subscribe{
	private static SubscribeBean subscribeBean;
	private static SubscribeCall subscribeCall;
	@BeforeClass
	public static void setUp() {
		Logger.createResultFile("直播订阅");
	}

	@Before
	public void caseUp() {
		subscribeBean=new SubscribeBean();
		subscribeCall=new SubscribeCall();
	}

	@AfterClass
	public static void tearDown() {
		Logger.generateResult(subscribeCall.getOpurl());
	}

	@After
	public void caseDown() {
		Logger.end();
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Ts_Subscribe_001() {
		Logger.start(true,"直播订阅，成功");
		try {
			//TODO 补全case代码
			int liveid=new LiveRoomWapper().selectLastLiveRoom().getId();
			int  userId=4085;
			subscribeBean.setLiveId(liveid);
			subscribeBean.setUserId(userId);
			subscribeCall.setData(subscribeBean);
			subscribeCall.callService();			
			Logger.verifyEquals("200", subscribeCall.getString("code"), "判断code");			
			Map m=new LiveRoomWapper().selectLiveSubscribeById(liveid,userId).get(0);
			Logger.verifyEquals(1, Integer.parseInt(m.get("Status").toString()),"验证OnlineNum");
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
}